home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MENU_UTL / DESIGN / MISCTOOL.PAS < prev    next >
Pascal/Delphi Source File  |  1989-02-23  |  2KB  |  105 lines

  1. unit MiscTool;
  2. interface
  3. uses CRT;
  4.  
  5. procedure Abort(M : String);
  6. { Simple fatal error reporter: Goes to the bottom of the screen,
  7.   Prints M and terminates execution of the program. }
  8.  
  9. procedure Beep;
  10. { Generates a sound from the speaker to alert the user.  Useful
  11.   for error handling routines. }
  12.  
  13. function ConstStr(C : Char; N : byte) : String;
  14. {  ConstStr returns a string with N characters of value C }
  15.  
  16. function Exist(FN : String) : boolean;
  17. { Returns true if file named by FN exists }
  18.  
  19. function NumStr(Num : integer) : String;
  20. { Converts an integer to a string.  Function form is often more
  21.   convenient than the Str procedure }
  22.  
  23. function UpcaseStr(S : String) : String;
  24. { Converts all characters in the string S to their upper case
  25.   equivalents. }
  26.  
  27. implementation
  28. {$V-}
  29.  
  30. procedure Beep;
  31. { Generates a sound from the speaker to alert the user.  Useful
  32.   for error handling routines. }
  33. begin
  34.   Sound(220);
  35.   Delay(200);
  36.   NoSound;
  37. end; { Beep }
  38.  
  39. function Exist(FN : String) : boolean;
  40. { Returns true if file named by FN exists }
  41. var
  42.   F : file;
  43.   found : boolean;
  44. begin
  45.   Assign(f, FN);
  46.   {$I-}
  47.   Reset(f);
  48.   Found := (IOResult = 0);
  49.   if Found then
  50.     Close(f);
  51.   {$I+}
  52.   Exist := Found;
  53. end; { Exist }
  54.  
  55. procedure Abort(M : String);
  56. { Simple fatal error reporter: Goes to the bottom of the screen,
  57.   Prints M and terminates execution of the program. }
  58.  
  59. begin
  60.   Window(1, 1, 80, 25);
  61.   TextColor(White);
  62.   TextBackground(Black);
  63.   LowVideo;
  64.   GotoXY(1, 25);
  65.   Write(M);
  66.   ClrEol;
  67.   Halt;
  68. end; { Abort }
  69.  
  70. function NumStr(Num : integer) : String;
  71. { Converts an integer to a string.  Function form is often more
  72.   convenient than the Str procedure }
  73. var
  74.   S : string;
  75.  
  76. begin
  77.   Str(Num:1, S);
  78.   NumStr := S;
  79. end;
  80.  
  81. function ConstStr(C : Char; N : byte) : String;
  82. {  ConstStr returns a string with N characters of value C }
  83.  
  84. var
  85.   S : string;
  86. begin
  87.   if N < 0 then
  88.     N := 0;
  89.   S[0] := Chr(N);
  90.   FillChar(S[1],N,C);
  91.   ConstStr := S;
  92. end; { ConstStr }
  93.  
  94. function UpcaseStr(S : String) : String;
  95. { Converts all characters in the string S to their upper case
  96.   equivalents. }
  97. var
  98.   P : byte;
  99. begin
  100.   for P := 1 to Length(S) do
  101.     S[P] := Upcase(S[P]);
  102.   UpcaseStr := S;
  103. end;
  104.  
  105. end.